package cn.jly.boot.starter;

import cn.jly.boot.starter.bean.AuthorProperties;
import cn.jly.boot.starter.service.AuthorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author lanyangji
 * @description 作者service自动配置
 * @date 2020/12/11 下午 2:46
 */
@Configuration
@EnableConfigurationProperties(AuthorProperties.class)
@ConditionalOnClass(AuthorService.class)
public class AuthorServiceAutoConfiguration {
    @Autowired
    private AuthorProperties authorProperties;

    @Bean
    public AuthorService authorService() {
        final AuthorService service = new AuthorService();
        service.setName(authorProperties.getName());
        service.setMsg(authorProperties.getMsg());
        return service;
    }
}
